package me.pearjelly.pmc.util;

public class PmsHelper {

	// http://m1.biz.itc.cn/pic/s/11/28/Img2212811_s.jpg
	public static final String[] IMGDOMAINS = ConfigManager.instance()
			.getProperty("index", "img.domains").split(",");
	private static int circleInt = 0;

	public static String genImgUri(Long id, String ext) {
		if (circleInt >= Integer.MAX_VALUE) {
			circleInt = 0;
		}
		int i = circleInt++ % IMGDOMAINS.length;
		String idstr = String.valueOf(id);
		return id < 10000 || ext == null ? idstr
				: new StringBuilder(IMGDOMAINS[i]).append("pic/s/").append(
						idstr.substring(idstr.length() - 2, idstr.length()))
						.append("/").append(
								idstr.substring(idstr.length() - 4, idstr
										.length() - 2)).append("/Img").append(
								id).append("_s.").append(ext).toString();
	}
}
